Developer Documentation
PATHJava Developer Documentation > Mac OS Runtime for Java > MRJToolkit > Programming With MRJToolkit


Finding Special Folders

The Mac OS platform has numerous special folders (that is, directories) that contain specialized files. For example, system extensions are stored in the Extensions folder, while fonts are stored in the Fonts folder. If your Java application accesses or saves files on the Mac OS platform, you may need to find the path to a special folder. For example, if you want to save application default settings, you should store these in the Preferences folder.

To find the path to a particular folder, you must call the findFolder method while specifying the folder you want to locate. Listing 1-4 shows a code fragment that locates the Preferences folder and prints out the path to standard output.

Listing 1-4 Finding the Preferences folder

try {
        System.out.println("Preferences folder is: " +
            MRJFileUtils.findFolder(
            MRJFileUtils.kPreferencesFolderType));
        }
catch (FileNotFoundException e) {
        fail("Couldn't get Preferences folder", e);
        return;
        }

The kPreferencesFolderType constant specifies that you are looking for the Preferences folder. See Special Folder Constants for a complete listing of possible folders and their constants.


© 1998 Apple Computer, Inc. — (Last Updated 10 Dec 98)